# 测试微信推送配置是否正确加载
$baseUrl = "http://localhost:5000"

# 测试生成微信消息XML接口
$testData = @{
    ServiceCode = "SendMessageNotice"
    PartnerId = "lzsfybjy73"
    TimeStamp = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
    CardNo = "772:test-uuid-123:1"
    MsgType = "4"
    MsgContext = (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
    PersonalFirst = "测试消息"
    PersonalSecond = "这是一条测试消息"
    Channel = "WX"
} | ConvertTo-Json

Write-Host "正在测试微信推送配置..." -ForegroundColor Yellow
Write-Host "请求数据: $testData" -ForegroundColor Cyan

try {
    $response = Invoke-RestMethod -Uri "$baseUrl/api/WeChatNotification/GenerateWeChatMessageXml" -Method Post -Body $testData -ContentType "application/json"
    Write-Host "测试成功!" -ForegroundColor Green
    Write-Host "响应: $response" -ForegroundColor Green
} catch {
    Write-Host "测试失败: $($_.Exception.Message)" -ForegroundColor Red
    if ($_.Exception.Response) {
        $reader = New-Object System.IO.StreamReader($_.Exception.Response.GetResponseStream())
        $responseBody = $reader.ReadToEnd()
        Write-Host "错误详情: $responseBody" -ForegroundColor Red
    }
}

Write-Host "测试完成" -ForegroundColor Yellow